<#-- 响应类模板 -->
package com.generated.${packageName};

import java.util.Map;
import java.util.HashMap;

/**
* ${apiName}操作响应
* <#if description?? && description.mark??>
    * ${description.mark}
    * </#if>
*/
public class ${apiName}Response {

private int statusCode;
private Map<String, java.util.List<String>> headers;
    private String body;
    <#list exitParameters as param>
        private ${getJavaType(param.type)} ${param.name};
    </#list>

    public ${apiName}Response() {
    this.headers = new HashMap<>();
    }

    // ========== 基础信息访问方法 ==========

    public int getStatusCode() {
    return statusCode;
    }

    public void setStatusCode(int statusCode) {
    this.statusCode = statusCode;
    }

    public Map<String, java.util.List<String>> getHeaders() {
        return headers;
        }

        public void setHeaders(Map<String, java.util.List<String>> headers) {
            this.headers = headers != null ? headers : new HashMap<>();
            }

            public String getBody() {
            return body;
            }

            public void setBody(String body) {
            this.body = body;
            }

            <#list exitParameters as param>
                // ========== ${param.name}访问方法 ==========
                <#if param.description?? && param.description.mark??>
                    /**
                    * ${param.description.mark}
                    */
                </#if>
                public ${getJavaType(param.type)} get${param.name?cap_first}() {
                return ${param.name};
                }

                public void set${param.name?cap_first}(${getJavaType(param.type)} ${param.name}) {
                this.${param.name} = ${param.name};
                }

            </#list>

            // ========== 工具方法 ==========

            /**
            * 判断请求是否成功（2xx状态码）
            */
            public boolean isSuccess() {
            return statusCode >= 200 && statusCode < 300;
            }

            /**
            * 获取特定响应头的值
            */
            public String getHeader(String name) {
            java.util.List<String> values = headers.get(name);
                return values != null && !values.isEmpty() ? values.get(0) : null;
                }

                /**
                * 获取响应内容类型
                */
                public String getContentType() {
                return getHeader("Content-Type");
                }

                @Override
                public String toString() {
                StringBuilder sb = new StringBuilder();
                sb.append("${apiName}Response{")
                .append("statusCode=").append(statusCode)
                .append(", success=").append(isSuccess())
                .append(", bodyLength=").append(body != null ? body.length() : 0);

                <#list exitParameters as param>
                    if (${param.name} != null) {
                    sb.append(", ${param.name}=").append(${param.name});
                    }
                </#list>

                sb.append('}');
                return sb.toString();
                }

                /**
                * 获取详细的调试信息
                */
                public String toDebugString() {
                return String.format(
                "${apiName}Response[status=%d, success=%s, headers=%d, body=%s]",
                statusCode, isSuccess(), headers.size(),
                body != null ? "'" + (body.length() > 100 ? body.substring(0, 100) + "..." : body) + "'" : "null"
                );
                }
                }